# -*- coding: utf-8 -*-
# @Software :   PyCharm
# @File     :   adminx.py
# @Author   :   zhaolie
# @Contact  :   zhaolie1989@gmail.com
# @Time     :   2019/11/16 10:31 下午
# @Desc     :   None      

# here put the import lib
import xadmin
from .models import CityDict, CourseOrg, Teacher


class CityDictAdmin:
    list_display = ["name", "desc", "add_time"]
    search_fields = ["name", "desc"]
    list_filter = ["name", "desc", "add_time"]

    def has_delete_permission(self,obj=None):
        return True


class CourseOrgAdmin:
    list_display = ["name", "desc", "click_nums", "fav_nums", "image", "address", "city", "add_time"]
    search_fields = ["name", "desc", "click_nums", "fav_nums", "image", "address", "city__name"]
    list_filter = ["name", "desc", "click_nums", "fav_nums", "address", "city__name", "add_time"]

    def has_delete_permission(self,obj=None):
        return True


class TeacherAdmin:
    list_display = ["org", "name", "work_years", "work_company", "work_position", "points",
                    "fav_nums","add_time"]
    search_fields = ["org__name", "name", "work_years", "work_company", "work_position", "points",
                     "fav_nums"]
    list_filter = ["org__name", "name", "work_years", "work_company", "work_position", "points",
                   "fav_nums","add_time"]

    def has_delete_permission(self,obj=None):
        return True


xadmin.site.register(CityDict, CityDictAdmin)
xadmin.site.register(CourseOrg, CourseOrgAdmin)
xadmin.site.register(Teacher, TeacherAdmin)
